//#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "user.h"
#include "user_doe.h"

static double A2,B2,h,w;
double UserNS2Fun(double u, double v) {
   u=u; v=v;
   return (rand() % 628)/100;
//return  1;
}

void UserNonSymm2()   {
   char *InputValues[5];
   char *Title={"   DOE : User NonSymmetric N1"};
   char *ParNames[]={"Hight              :",
		     "Width              :",
		     "Discretization Step:",
		     "A                  :",
		     "B                  :"};
   char *Default[]={"256", "256","1", "2", "3"};
   if(!sedit(25,5,5,ParNames,InputValues,Default,Title))  return ;

   // read input data
   double s;
   double a,b;
   sscanf(InputValues[0],"%lf \0",&h);
   sscanf(InputValues[1],"%lf \0",&w);
   sscanf(InputValues[2],"%lf \0",&s);
   sscanf(InputValues[3],"%lf \0",&a);
   sscanf(InputValues[4],"%lf \0",&b);
   A2=a*a;
   B2=b*b;

   // max&min values of phase in this mask
   double max=3.14;
   double min=0;
   NonSymmetricDOE(Phase, max, min, UserNS2Fun);

   // control the DOE sizes and output they to InfoWindow
   // if sizes wrong (very big) - return
   if(MessageSize(w, h, s)) return;
   // Output information to InfoWindow
   MessageName("NonSymmetric DOE N1");  // write title
   MessageParam(1,"  f= u**2/A**2 + v**2/B**2");
   MessageParam(2,"Hight  %f",h);
   MessageParam(3,"Width  %f",w);
   MessageParam(4,"Step   %f",s);
   MessageParam(5,"   A = %f",a);
   MessageParam(6,"   B = %f",b);
   MessageOut();                  // output all string to InfoWindow

   UndoMenu(3) ;   //  delete 3 last level submenu on the screen
   return;
}
